import React from "react"
import * as UI from 'antd-mobile'
import * as ICON from 'antd-mobile-icons'

import request from "@/services/request"

import cookies from 'react-cookies'

React.UI = UI
React.ICON = ICON
React.request = request
React.cookies = cookies

React.business = <object | null>React.cookies.load('business') ?? {}

React.toast = (msg: string, type?: string, callback?: any):void => {
    React.UI.Toast.show({
        icon: type ? type : 'success',
        content: msg,
        duration: 1500,
        afterClose: () => {
            if(!callback) return

            if(typeof callback === 'string') callback === 'back' ? React.navigate(-1) : React.navigate(callback)

            else callback()
        }
    })
}

// 不需要登录的路由
React.RouterRules = [
    '/',
    '/business/login'
]

export default {}